package com.example.magnet.nettyLogic.service;

import com.example.magnet.nettyLogic.dto.FightRoomEntity;
import com.iohao.game.widget.light.room.GameRoomService;
import com.iohao.game.widget.light.room.Player;
import com.iohao.game.widget.light.room.Room;
import com.iohao.game.widget.light.room.flow.GameFlowContext;
import com.iohao.game.widget.light.room.flow.RoomCreateContext;
import com.iohao.game.widget.light.room.operation.OperationFactory;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Getter
@Slf4j
public class MyGameRoomService implements GameRoomService {
    /** 房间 map */
    final Map<Long, FightRoomEntity> roomMap = new ConcurrentHashMap<>();
    /** 玩家对应的房间 map */
    final Map<Long, Long> userRoomMap = new ConcurrentHashMap<>();
    /** 玩法操作工厂 */
    final OperationFactory operationFactory = OperationFactory.of();

    @Override
    public Room createRoom(RoomCreateContext createContext) {
        // 创建房间
        return null;
    }

    @Override
    public Player createPlayer(GameFlowContext gameFlowContext) {
        log.info("创建玩家");
        // 创建玩家
        return null;
    }

    @Override
    public void enterRoom(GameFlowContext gameFlowContext) {
        log.info("玩家进入房间");
        // 玩家进入房间 (重连)
    }

    @Override
    public void startGameVerify(GameFlowContext gameFlowContext) {
        log.info("游戏开始前的逻辑校验");
        // 游戏开始前的逻辑校验
    }

    @Override
    public void startGameVerifyAfter(GameFlowContext gameFlowContext) {
        log.info("游戏开始");
        // 游戏开始，会在 startGameVerify 校验成功后执行
    }
    
    @Override
    public void dissolveRoom(GameFlowContext gameFlowContext) {
        log.info("解散房间");
        // 解散房间
    }

    @Override
    public void quitRoom(GameFlowContext gameFlowContext) {
        log.info("玩家退出房间");
        // 玩家退出房间
    }

    @Override
    public void ready(boolean ready, GameFlowContext gameFlowContext) {
        log.info("玩家准备");
        // 玩家准备
    }
}